package com.mc.web;

import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;


import com.mc.model.Article;

import com.mc.model.IndexImage;

import com.mc.model.Path;
import com.mc.model.newsandbulletin;

import com.mc.service.ArticleService;

import com.mc.service.IIndexImageService;

import com.mc.service.NewsandbulletService;
import com.mc.utils.PathUtil;
import com.mc.utils.StringUtil;

@Controller
@RequestMapping("/studentwork")
public class StudentWorkAction {

	@Autowired private NewsandbulletService newsandbulletService;

	@Autowired private ArticleService articleService;

	@Autowired private IIndexImageService indexImageService;

	private Path path = null;
	/**
	 * 师资队伍
	 * @param modelMap
	 * @return
	 */
	@RequestMapping("/studentworkindex")
	public String bkpy(ModelMap modelMap)
	{
		
		List<newsandbulletin> bulletins= newsandbulletService.selectstudentbulletins();
		
		//查询相关文章
		List<Article> articles = articleService.selectByMenuName("学生工作");
		//查询子菜单名称
		Set<String> subMenuNames = articleService.getSubMenuNames(articles);
		
		StringUtil.getInstace().replaceTitle(bulletins);
		List<newsandbulletin> news  = newsandbulletService.selectstudentnews();
		StringUtil.getInstace().replaceTitle(news);
		modelMap.addAttribute("bulletins", bulletins);
		modelMap.addAttribute("news",news);

		modelMap.addAttribute("articles",articles);
		modelMap.addAttribute("subMenuNames",subMenuNames);

		List<newsandbulletin> picnews = newsandbulletService.newsbytype(8);
		modelMap.addAttribute("picnews",picnews);
		List<IndexImage> images = indexImageService.imagesbytype(3);
		modelMap.addAttribute("images",images);

		path = PathUtil.setPathParams(new String[]{"PackageName:StudentWork","ViewName:xsgz","ViewTitle:学生工作","smenu:studentwork","mmenu:studentworkindex"});				
		return PathUtil.returnStr(path, modelMap);
	}
}
